package com.slkj.shilixiaoyuanapp.view;

import android.content.Context;
import android.content.DialogInterface;
import android.widget.Toast;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;

/**
 * Created  on 2018-07-19
 * @author 唐开阔
 * @describe Dialog，方便统一修改
 */
public class DialogProvider {

    /**
     * 选择图片
     * @param context
     * @param listener
     * @return
     */
    public static void getPhotoDialog(Context context,TakePicTypeListener listener){
//        return  new MaterialDialog.Builder(context)
//                .items("选择本地照片", "拍照")
//                .itemsCallback((dialog, itemView, position, text) -> {
//                    switch (position) {
//                        case 0: // 选择本地照片
//                            listener.chosePhoto();
//                            break;
//                        case 1: // 拍照
//                            listener.takePhoto();
//                            break;
//                    }
//                });
        final String[] items = new String[]{"选择本地照片", "拍照"};
        new QMUIDialog.MenuDialogBuilder(context)
                .addItems(items, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        switch (which) {
                            case 0: // 选择本地照片
                                listener.chosePhoto();
                                break;
                            case 1: // 拍照
                                listener.takePhoto();
                                break;
                        }
                        dialog.dismiss();
                    }
                })
                .create( com.qmuiteam.qmui.R.style.QMUI_Dialog).show();
    }






    /**
     * 拍照或者选择图片
     */
    public interface TakePicTypeListener{
        void takePhoto();
        void chosePhoto();

    }
}
